package com.jwdf.uda.http.action;

import android.content.Context;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpService;
import com.jwdf.uda.http.ApiService;

import retrofit2.Call;

/**
 * Created by Administrator on 2016/9/8.
 */
public class QuizVoteInfoAction extends AHttpService<PbBean.PbResQuestionVoteInfo> {
    private int quizId;
    private int offset = -1;

    private QuizVoteInfoAction(Context context, int quizId) {
        super(context);
        this.quizId = quizId;
    }

    private QuizVoteInfoAction(Context context, int quizId, int offset) {
        super(context);
        this.quizId = quizId;
        this.offset = offset;
    }

    public static QuizVoteInfoAction newInstance(Context context, int quizId) {
        return new QuizVoteInfoAction(context, quizId);
    }

    public static QuizVoteInfoAction newInstance(Context context, int quizId, int offset) {
        return new QuizVoteInfoAction(context, quizId, offset);
    }

    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqQuestionVoteInfo.Builder builder = PbBean.PbReqQuestionVoteInfo.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        builder.setQuestionId(quizId);
        if (offset >= 0) {
            builder.setOffset(offset);
        }
        return apiService.getQuizVote(builder.build());
    }
}
